// ============================== 导入依赖 ============================== //

import MAP from './MAP'
import DICT from './DICT'
import STORE from './STORE'
import THEME from './THEME'
import ROUTE from './ROUTE'

import TIME from './TIME'
import FILE from './FILE'
import GRPC from './GRPC'
import AXIOS from './AXIOS'
import SOCKET from './SOCKET'

import MSG from './MSG'
import ALERT from './ALERT'
import CONFIRM from './CONFIRM'
import PROMPT from './PROMPT'

import UTIL from './UTIL'

import { current } from './UTIL/init'

const VERSION = process.env.CORE_VERSION
const PROXY = process.env.VUE_APP_DEBUG_PROXY || 'http://ibdev.hzzxinfo.com'

// ============================== 导出内核 ============================== //

export default {
  VERSION, // 内核版本
  PROXY, // 代理地址

  CACHE: { SVG: {} }, // 公共缓存
  USER: {}, // 公共用户

  MENU: { TREE: [], MAP: {}, DICT: [], NAME: {}, ROUTE: {}, current }, // 菜单
  ORGAN: { TREE: [], MAP: {}, DICT: [], NAME: {}, MY_TREE: [], MY_MAP: {}, MY_DICT: [] }, // 组织
  REGION: { TREE: [], MAP: {}, DICT: [], NAME: {}, MY_TREE: [], MY_MAP: {}, MY_DICT: [] }, // 区域
  DISTRICT: { TREE: [], MAP: {}, DICT: [], NAME: {}, PROVINCE: [], CITY: [], AREA: [] }, // 行政区

  MAP, // 公共映射
  DICT, // 公共字典
  STORE, // 公共仓库
  THEME, // 公共主题
  ROUTE, // 公共路由

  TIME, // 时间配置
  FILE, // 文件配置
  GRPC, // GRPC 配置
  AXIOS, // AXIOS 配置
  SOCKET, // SOCKET 配置

  MSG, // 消息配置
  ALERT, // 提示配置
  CONFIRM, // 确认配置
  PROMPT, // 提交配置

  WEB: { BASE: {} }, // CORE_WEB 组件配置

  WATCH: {}, // 自定义监听项

  modalCount: 0, // 已弹窗个数

  ...UTIL, // 工具方法
}

// ============================== 版本校验 ============================== //

const key = `VERSION_${process.env.VUE_APP_TAG}`
if (sessionStorage[key]) {
  if (sessionStorage[key] !== `${VERSION}`) sessionStorage.clear()
} else {
  sessionStorage[key] = `${VERSION}`
}
